package com.lechicanh.cgrid.ke.handler.service;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.logging.Logger;

import com.lechicanh.cgrid.ke.api.resource.Resource;
import com.lechicanh.cgrid.ke.api.resource.ServiceName;

public class HandlerServiceDeployment {
	private static final Logger m_logger = Logger.getLogger(HandlerServiceDeployment.class.getSimpleName());
	public static void deploy(long fromPage, long toPage) throws RemoteException{
		deploy(Resource.RMI_PORT, fromPage, toPage);
	}
	
	public static void deploy(int port, long fromPage, long toPage) throws RemoteException{
		System.out.println("Deploy " + ServiceName.HANDLER_SERVICE + ", port:" + port +", from page:" + fromPage + ", to page: " + toPage);
		Registry registry = LocateRegistry.createRegistry(Resource.RMI_PORT);
		registry.rebind(ServiceName.HANDLER_SERVICE, new HandlerServiceImpl(fromPage, toPage));
	}
}
